
#include "main-tools.h"
//necessary
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "memory-tools.h"


void initLibrary(){
	resetMemoryObservation();
}

char* initString(char* str){
	char* result=(char*)mallocMemory(strlen(str)+1,"main-tools.c:initString:1");
	strcpy(result,str);
	return result;
}

char* initCString(char* str){
	int length=strlen(str);
	char* result=(char*)mallocMemory(length+1-2,"main-tools.c:initString:1");
	char* strstart=result;
	str++; //the first quote must be ignored
	while (!(*str=='\"'&&(*(str+1)=='\0'))){//must stop if the current char is quote and the char after quote is actually \0
		*result++=*str++;
	}
	*result++='\0';
	return strstart;
}

void freeString(char* str){
	freeMemory(strlen(str)+1,str);
}

void printTabs(FILE* f,int tabsnumber){
	int i;
	for (i=0;i<tabsnumber;i++){
		fprintf(f,"\t");
	}
}
